home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / OpenTransportUNIX.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  9.8 KB  |  477 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        OpenTransportUNIX.h
  3.  
  4.      Contains:    Open Transport client interface file for UNIX compatibility clients.
  5.  
  6.      Version:    Technology:    2.5
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1993-1999 by Apple Computer, Inc. and Mentat Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __OPENTRANSPORTUNIX__
  18. #define __OPENTRANSPORTUNIX__
  19.  
  20. #include <stddef.h>
  21. #ifndef __OPENTRANSPORTPROTOCOL__
  22.     #include <OpenTransportProtocol.h>
  23. #endif
  24.  
  25.  
  26.  
  27.  
  28. #if PRAGMA_ONCE
  29. #pragma once
  30. #endif
  31.  
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35.  
  36. #if PRAGMA_IMPORT
  37. #pragma import on
  38. #endif
  39.  
  40. #if PRAGMA_STRUCT_ALIGN
  41.     #pragma options align=mac68k
  42. #elif PRAGMA_STRUCT_PACKPUSH
  43.     #pragma pack(push, 2)
  44. #elif PRAGMA_STRUCT_PACK
  45.     #pragma pack(2)
  46. #endif
  47.  
  48. #if defined(__MWERKS__) && TARGET_CPU_68K
  49.     #pragma push
  50.     #pragma pointers_in_D0
  51. #endif
  52.  
  53. /* ***** Global Variables ******/
  54.  
  55. extern int t_errno;
  56.  
  57. /* ***** XTI Structures ******/
  58.  
  59. /*
  60.    WARNING:
  61.    These structures will only work if "int"s are the
  62.    same size as "size_t", "long", and "UInt32".  We left
  63.    them this way for maximum UNIX compatibility.
  64. */
  65.  
  66.  
  67. struct netbuf {
  68.     unsigned int                     maxlen;
  69.     unsigned int                     len;
  70.     char *                            buf;
  71. };
  72. typedef struct netbuf                    netbuf;
  73.  
  74. struct t_info {
  75.     int                             addr;                        /* Maximum size of an address            */
  76.     int                             options;                    /* Maximum size of options                */
  77.     int                             tsdu;                        /* Standard data transmit unit size        */
  78.     int                             etsdu;                        /* Expedited data transmit unit size    */
  79.     int                             connect;                    /* Maximum data size on connect            */
  80.     int                             discon;                        /* Maximum data size on disconnect        */
  81.     unsigned int                     servtype;                    /* service type                            */
  82.     unsigned int                     flags;                        /* Flags (see "OpenTransport.h")        */
  83. };
  84. typedef struct t_info                    t_info;
  85.  
  86. struct t_bind
  87. {
  88.     netbuf                addr;
  89.     unsigned int        qlen;
  90. };
  91. struct t_optmgmt
  92. {
  93.     netbuf            opt;
  94.     long            flags;
  95. };
  96.  
  97. struct t_discon {
  98.     netbuf                             udata;
  99.     int                             reason;
  100.     int                             sequence;
  101. };
  102. typedef struct t_discon                    t_discon;
  103.  
  104. struct t_call {
  105.     netbuf                             addr;
  106.     netbuf                             opt;
  107.     netbuf                             udata;
  108.     int                             sequence;
  109. };
  110. typedef struct t_call                    t_call;
  111.  
  112. struct t_unitdata {
  113.     netbuf                             addr;
  114.     netbuf                             opt;
  115.     netbuf                             udata;
  116. };
  117. typedef struct t_unitdata                t_unitdata;
  118.  
  119. struct t_uderr {
  120.     netbuf                             addr;
  121.     netbuf                             opt;
  122.     long                             error;
  123. };
  124. typedef struct t_uderr                    t_uderr;
  125. /*    -------------------------------------------------------------------------
  126.     Transaction data structures
  127.     ------------------------------------------------------------------------- */
  128.  
  129. struct t_request {
  130.     netbuf                             data;
  131.     netbuf                             opt;
  132.     long                             sequence;
  133. };
  134. typedef struct t_request                t_request;
  135.  
  136. struct t_reply {
  137.     netbuf                             data;
  138.     netbuf                             opt;
  139.     long                             sequence;
  140. };
  141. typedef struct t_reply                    t_reply;
  142.  
  143. struct t_unitrequest {
  144.     netbuf                             addr;
  145.     netbuf                             opt;
  146.     netbuf                             udata;
  147.     long                             sequence;
  148. };
  149. typedef struct t_unitrequest            t_unitrequest;
  150.  
  151. struct t_unitreply {
  152.     netbuf                             opt;
  153.     netbuf                             udata;
  154.     long                             sequence;
  155. };
  156. typedef struct t_unitreply                t_unitreply;
  157.  
  158. struct t_opthdr {
  159.     unsigned long                     len;                        /* total length of option = sizeof(struct t_opthdr) +    */
  160.                                                                 /*                        length of option value in bytes    */
  161.     unsigned long                     level;                        /* protocol affected */
  162.     unsigned long                     name;                        /* option name */
  163.     unsigned long                     status;                        /* status value */
  164.                                                                 /* followed by the option value */
  165. };
  166. typedef struct t_opthdr                    t_opthdr;
  167. /* ***** XTI Interfaces ******/
  168. #if !OTKERNEL
  169. EXTERN_API( int )
  170. t_accept                        (int                     fd,
  171.                                  int                     resfd,
  172.                                  t_call *                call);
  173.  
  174. EXTERN_API( char *)
  175. t_alloc                            (int                     fd,
  176.                                  int                     struct_type,
  177.                                  int                     fields);
  178.  
  179. EXTERN_API( int ) t_bind(int fd, struct t_bind* req, struct t_bind* ret);
  180. EXTERN_API( int )t_optmgmt(int fd, struct t_optmgmt* req, struct t_optmgmt* ret);
  181. EXTERN_API( int ) t_getprotaddr(int fd, struct t_bind* boundaddr, struct t_bind* peeraddr);
  182. EXTERN_API( int ) t_resolveaddr(int fd, struct t_bind* reqAddr, struct t_bind* retAddr, OTTimeout timeout);
  183. EXTERN_API( int )
  184. t_close                            (int                     fd);
  185.  
  186. EXTERN_API( int )
  187. t_connect                        (int                     fd,
  188.                                  t_call *                sndcall,
  189.                                  t_call *                rcvcall);
  190.  
  191. EXTERN_API( int )
  192. t_free                            (char *                    ptr,
  193.                                  int                     struct_type);
  194.  
  195. EXTERN_API( int )
  196. t_getinfo                        (int                     fd,
  197.                                  t_info *                info);
  198.  
  199. EXTERN_API( int )
  200. t_getstate                        (int                     fd);
  201.  
  202. EXTERN_API( int )
  203. t_listen                        (int                     fd,
  204.                                  t_call *                call);
  205.  
  206. EXTERN_API( int )
  207. t_look                            (int                     fd);
  208.  
  209. EXTERN_API( int )
  210. t_open                            (char *                    path,
  211.                                  int                     oflag,
  212.                                  t_info *                info);
  213.  
  214. EXTERN_API( int )
  215. t_blocking                        (int                     fd);
  216.  
  217. EXTERN_API( int )
  218. t_nonblocking                    (int                     fd);
  219.  
  220. EXTERN_API( int )
  221. t_rcv                            (int                     fd,
  222.                                  char *                    buf,
  223.                                  size_t                 nbytes,
  224.                                  int *                    flags);
  225.  
  226. EXTERN_API( int )
  227. t_rcvconnect                    (int                     fd,
  228.                                  t_call *                call);
  229.  
  230. EXTERN_API( int )
  231. t_rcvdis                        (int                     fd,
  232.                                  t_discon *                discon);
  233.  
  234. EXTERN_API( int )
  235. t_rcvrel                        (int                     fd);
  236.  
  237. EXTERN_API( int )
  238. t_rcvudata                        (int                     fd,
  239.                                  t_unitdata *            unitdata,
  240.                                  int *                    flags);
  241.  
  242. EXTERN_API( int )
  243. t_rcvuderr                        (int                     fd,
  244.                                  t_uderr *                uderr);
  245.  
  246. EXTERN_API( int )
  247. t_snd                            (int                     fd,
  248.                                  char *                    buf,
  249.                                  size_t                 nbytes,
  250.                                  int                     flags);
  251.  
  252. EXTERN_API( int )
  253. t_snddis                        (int                     fd,
  254.                                  t_call *                call);
  255.  
  256. EXTERN_API( int )
  257. t_sndrel                        (int                     fd);
  258.  
  259. EXTERN_API( int )
  260. t_sndudata                        (int                     fd,
  261.                                  t_unitdata *            unitdata);
  262.  
  263. EXTERN_API( int )
  264. t_sync                            (int                     fd);
  265.  
  266. EXTERN_API( int )
  267. t_unbind                        (int                     fd);
  268.  
  269. EXTERN_API( int )
  270. t_error                            (char *                    errmsg);
  271.  
  272. /* Apple extensions*/
  273.  
  274. EXTERN_API( int )
  275. t_isnonblocking                    (int                     fd);
  276.  
  277. EXTERN_API( int )
  278. t_asynchronous                    (int                     fd);
  279.  
  280. EXTERN_API( int )
  281. t_synchronous                    (int                     fd);
  282.  
  283. EXTERN_API( int )
  284. t_issynchronous                    (int                     fd);
  285.  
  286. EXTERN_API( int )
  287. t_usesyncidleevents                (int                     fd,
  288.                                  int                     useEvents);
  289.  
  290. /* Not XTI standard functions, but extensions for transaction endpoints    */
  291.  
  292. EXTERN_API( int )
  293. t_sndrequest                    (int                     fd,
  294.                                  t_request *            req,
  295.                                  int                     flags);
  296.  
  297. EXTERN_API( int )
  298. t_rcvreply                        (int                     fd,
  299.                                  t_reply *                rep,
  300.                                  int *                    flags);
  301.  
  302. EXTERN_API( int )
  303. t_rcvrequest                    (int                     fd,
  304.                                  t_request *            req,
  305.                                  int *                    flags);
  306.  
  307. EXTERN_API( int )
  308. t_sndreply                        (int                     fd,
  309.                                  t_reply *                rep,
  310.                                  int                     flags);
  311.  
  312. EXTERN_API( int )
  313. t_cancelrequest                    (int                     fd,
  314.                                  long                     sequence);
  315.  
  316. EXTERN_API( int )
  317. t_cancelreply                    (int                     fd,
  318.                                  long                     sequence);
  319.  
  320. EXTERN_API( int )
  321. t_sndurequest                    (int                     fd,
  322.                                  t_unitrequest *        ureq,
  323.                                  int                     flags);
  324.  
  325. EXTERN_API( int )
  326. t_rcvureply                        (int                     fd,
  327.                                  t_unitreply *            urep,
  328.                                  int *                    flags);
  329.  
  330. EXTERN_API( int )
  331. t_rcvurequest                    (int                     fd,
  332.                                  t_unitrequest *        ureq,
  333.                                  int *                    flags);
  334.  
  335. EXTERN_API( int )
  336. t_sndureply                        (int                     fd,
  337.                                  t_unitreply *            urep,
  338.                                  int                     flags);
  339.  
  340. EXTERN_API( int )
  341. t_cancelurequest                (int                     fd,
  342.                                  long                     sequence);
  343.  
  344. EXTERN_API( int )
  345. t_cancelureply                    (int                     fd,
  346.                                  long                     sequence);
  347.  
  348. EXTERN_API( int )
  349. t_cancelsynchronouscalls        (int                     fd);
  350.  
  351. EXTERN_API( int )
  352. t_installnotifier                (int                     fd,
  353.                                  OTNotifyProcPtr         proc,
  354.                                  void *                    contextPtr);
  355.  
  356. EXTERN_API( void )
  357. t_removenotifier                (int                     fd);
  358.  
  359. /* STREAMS Primitives*/
  360.  
  361. EXTERN_API( int )
  362. getmsg                            (int                     fd,
  363.                                  strbuf *                ctlbuf,
  364.                                  strbuf *                databuf,
  365.                                  int *                    flagsp);
  366.  
  367. EXTERN_API( int )
  368. putmsg                            (int                     fd,
  369.                                  const strbuf *            ctlbuf,
  370.                                  const strbuf *            databuf,
  371.                                  int                     flags);
  372.  
  373. EXTERN_API( int )
  374. getpmsg                            (int                     fd,
  375.                                  strbuf *                ctlbuf,
  376.                                  strbuf *                databuf,
  377.                                  int *                    bandp,
  378.                                  int *                    flagsp);
  379.  
  380. EXTERN_API( int )
  381. putpmsg                            (int                     fd,
  382.                                  const strbuf *            ctlbuf,
  383.                                  const strbuf *            databuf,
  384.                                  int                     band,
  385.                                  int                     flags);
  386.  
  387. /* Raw streams operations.*/
  388.  
  389. EXTERN_API( int )
  390. stream_installnotifier            (int                     fd,
  391.                                  OTNotifyProcPtr         proc,
  392.                                  void *                    contextPtr);
  393.  
  394. EXTERN_API( int )
  395. stream_blocking                    (int                     fd);
  396.  
  397. EXTERN_API( int )
  398. stream_nonblocking                (int                     fd);
  399.  
  400. EXTERN_API( int )
  401. stream_isblocking                (int                     fd);
  402.  
  403. EXTERN_API( int )
  404. stream_synchronous                (int                     fd);
  405.  
  406. EXTERN_API( int )
  407. stream_asynchronous                (int                     fd);
  408.  
  409. EXTERN_API( int )
  410. stream_issynchronous            (int                     fd);
  411.  
  412. EXTERN_API( int )
  413. stream_open                        (char *                    path,
  414.                                  unsigned long             flags);
  415.  
  416. EXTERN_API( int )
  417. stream_close                    (int                     fd);
  418.  
  419. EXTERN_API( int )
  420. stream_read                        (int                     fd,
  421.                                  void *                    buf,
  422.                                  size_t                 len);
  423.  
  424. EXTERN_API( int )
  425. stream_write                    (int                     fd,
  426.                                  void *                    buf,
  427.                                  size_t                 len);
  428.  
  429. EXTERN_API_C( int )
  430. stream_ioctl                    (int                     fd,
  431.                                  unsigned long             cmd,
  432.                                  ...);
  433.  
  434. EXTERN_API( int )
  435. stream_pipe                        (int *                    fds);
  436.  
  437.  
  438. struct pollfd {
  439.     SInt32                             fd;
  440.     short                             events;
  441.     short                             revents;
  442.     long                             _ifd;                        /* Internal "fd" for the benefit of the kernel */
  443. };
  444. typedef struct pollfd                    pollfd;
  445. EXTERN_API( int )
  446. poll                            (pollfd *                fds,
  447.                                  size_t                 nfds,
  448.                                  unsigned long             timeout);
  449.  
  450. #endif  /* !OTKERNEL */
  451.  
  452.  
  453. #if defined(__MWERKS__) && TARGET_CPU_68K
  454.     #pragma pop
  455. #endif
  456.  
  457. #if PRAGMA_STRUCT_ALIGN
  458.     #pragma options align=reset
  459. #elif PRAGMA_STRUCT_PACKPUSH
  460.     #pragma pack(pop)
  461. #elif PRAGMA_STRUCT_PACK
  462.     #pragma pack()
  463. #endif
  464.  
  465. #ifdef PRAGMA_IMPORT_OFF
  466. #pragma import off
  467. #elif PRAGMA_IMPORT
  468. #pragma import reset
  469. #endif
  470.  
  471. #ifdef __cplusplus
  472. }
  473. #endif
  474.  
  475. #endif /* __OPENTRANSPORTUNIX__ */
  476.  
  477.